﻿<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="/WEB-INF/datetag.tld" prefix="datetag"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta msg="renderer" content="webkit|ie-stand">
    <meta content="工作圈" msg="Keywords">
    <meta msg="description" content="聊工作 上工作圈" />

    <link rel="stylesheet" type="text/css"
          href="../resource/css/bootstrap.min.css">
    <link href="${cssPath}/base.css?v=${css_version}" rel="stylesheet"
          type="text/css">
    <link href="${cssPath}/code.css?v=${css_version}" rel="stylesheet"
          type="text/css">
    <link href="${context_path}/resource/css/common.css?v=${css_version}"
          rel="stylesheet" type="text/css">


    <script type="text/javascript" src="${jsPath}/Dojo/dojo/dojo.js"></script>
    <script type="text/javascript"
            src="${context_path}/resource/js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript"
            src="${context_path}/resource/js/calendar/laydate.js"></script>
    <script type="text/javascript"
            src="${context_path}/resource/js/lib/bootstrap.js"></script>

    <link rel="stylesheet" type="text/css" media="screen"
          href="${context_path}/resource/jquery.jqGrid-4.4.3/css/ui.jqgrid.css" />
    <script src="${context_path}/resource/jquery.jqGrid-4.4.3/js/jquery-1.7.2.min.js"
            type="text/javascript"></script>
    <script src="${context_path}/resource/jquery.jqGrid-4.4.3/js/jquery.jqGrid.min.js"
            type="text/javascript"></script>
    <script src="${context_path}/resource/EasyUI/jquery.easyui.min.js"
            type="text/javascript"></script>
    <link href="${context_path}/resource/EasyUI/themes/default/easyui.css"
          rel="stylesheet" type="text/css" />

    <style>
        * {
            box-sizing: content-box;
            -moz-box-sizing: content-box;
            -webkit-box-sizing: content-box;
        }
    </style>
    <title>工作圈运营后台管理</title>
</head>
<body style="background: #f8f8f8;">
    <div class="tw_container" id="container">
        <table id="frametable" cellpadding="0" cellspacing="0" width="100%"
               height="100%" style="width: 100%;">
            <tr cellspacing="0" cellpadding="0">
                <td>
                    <div class="header">
                        <jsp:include page="common/header.jsp"></jsp:include>
                    </div>
                </td>
            </tr>
            <tr>
                <td valign="top" width="150" height="100%">
                    <jsp:include page="common/leftnav.jsp"></jsp:include>
                </td>
                <td valign="top" width="100%" height="100%"
                    style="padding: 10px; background: none repeat scroll 0% 0% #F5F5F5">
                    <br> <jsp:include page="common/navtop.jsp">
                        <jsp:param value="impService" msg="pageFlag" />
                    </jsp:include>
                    <div class="wk_creatTop">

                        <table id="list4"></table>
                        <div>
                            <input type="button" value="增加AutoId" id="addone2" style="display:none" /> <input type="button" value="增加CustomId" id="addoneCustom" /> <input type="button" value="修改" id="modifyone" /> <input type="button"
                                                                                                                                                                                                                             value="查看" id="view" />
                        </div>

                        <br />
                        <div id="modify">
                            id: <input type="text" id="id" />id 外部获取相关信息的id, 消息推送的发送者<br />
                            msg: <input type="text" id="msg" />显示名称, session 上显示的名字<br />
                            appId: <input type="text" id="appId" value="1" />session上显示
                            (0默认不显示有消息要显示, 1强制显示)<br /> from: <input type="text"
                                                                     id="from" value="0" />0 不能删除 1 可删除 2 费除不用<br /> parentId:
                            <input type="text" id="parentId" value="0" />折叠显示时, 指定的父类id 0
                            无父类, 即是 id, 指定的父一级id, 构成树状显示结构<br />  type: <input type="text"
                                                                               id="type" value="0" />0 显示消息列表 1 显示子类列表 2 进入特定地址 3 消息只查看， 点击后<br />
                            createTime: <input type="text" style="width:70%" id="createTime" /><br />
                            creator: <input type="text" style="width:70%" id="creator" /><br />
                            value: <input type="text" id="value" /><br />  <br /> <br /><br /><br /><input type="button" value="确定"
                                                                                         id="ddookk" /> <input type="button" value="取消" id="dcancel" />
                        </div>
                    </div>
</body>
<script type="text/javascript">

	function SessionIconItem() {
		this.id = -1000;
		this.appId="gzq";
		this.parentId =-1;
		this.from =50000009997;
		this.msg="";
		this.type="";
		this.value="";
		this.createTime = 0;
		this.creator="";
	};

$("#addone").click(function() {

	$.ajax({
		type : "POST",
		url : "/back/getNextNewOne",
		data : "",
		dataType : 'text',
		async: false,
		success : function(data) {
			var dd = JSON.parse(data);
			if ( dd.code==0 ){
				setViewVal(dd.data);
			    $("#modify").dialog({
			        autoOpen: false, // 是否自动弹出窗口
			        modal: true, // 设置为模态对话框
			        resizable: true,
			        width: 800,
			        height: 400,
			        position: "center" // 窗口显示的位置
			    });
			}
			else
				alert(dd.msg);
		}
	});

});


$("#addoneCustom").click(function() {

	var item = new SessionIconItem();
	setViewVal(item);
    $("#modify").dialog({
        autoOpen: false, // 是否自动弹出窗口
        modal: true, // 设置为模态对话框
        resizable: true,
        width: 800,
        height: 400,
        position: "center" // 窗口显示的位置
    });
});

$("#ddookk").click(function() {
	this.id = -1000;
	this.appId="gzq";
	this.parentId =-1;
	this.from =50000009997;
	this.msg="";
	this.type="";
	this.value="";
	this.createTime = 0;
	this.creator="";
	var sess = new SessionIconItem();
	sess.id=$("#id").val();
	sess.msg=$("#msg").val();
	sess.appId = $("#appId").val();
	sess.from=$("#from").val();
	sess.parentId=$("#parentId").val();
	sess.value = $("#value").val();
	sess.type=$("#type").val();
	sess.createTime=$("#createTime").val();
	sess.creator=$("#creator").val();

	$.ajax({
		type : "POST",
		url : "/back/saveOrModifyImpService",
		data : "str="+JSON.stringify(sess),
		dataType : 'text',
		success : function(data) {
			var dd = JSON.parse(data);
			if ( dd.code == 1)
				location.href = "/back/ImpService";
			else if ( dd.code==0 )
				location.href = "/back/ImpService";
			else
				alert(dd.msg);
		}
	});
	$("#id").removeAttr("disabled");

});

$("#dcancel").click(function() {

	$("#id").removeAttr("disabled");

});

$("#view").click(function() {
	var id=$("#list4").jqGrid("getGridParam","selrow");
	var ret = $("#list4").jqGrid("getRowData", id);

	alert(JSON.stringify(ret));
});



$("#modifyone").click(function() {

	$("#id").attr("disabled", "disabled");
	var id=$("#list4").jqGrid("getGridParam","selrow");
	if ( id==null ){
		alert("请选择")
		return;
	}

	var ret = $("#list4").jqGrid("getRowData", id);
	setViewVal(ret);


    $("#modify").dialog({
        autoOpen: false, // 是否自动弹出窗口
        modal: true, // 设置为模态对话框
        resizable: true,
        width: 800,
        height: 400,
        position: "center" // 窗口显示的位置
    });

});

function setViewVal(ret){
	$("#id").val(ret.id);
	$("#msg").val(ret.msg);
	$("#appId").val(ret.appId);
	$("#from").val(ret.from);
	$("#parentId").val(ret.parentId);
	$("#type").val(ret.type);
	$("#createTime").val(ret.createTime);
	$("#creator").val(ret.creator);
}



$(function () {
    pageInit();
});
function pageInit() {
    jQuery("#list4").jqGrid(
        {

            datatype: "local",
            height: 650,
            colNames: ['id', 'msg', 'appId', 'from', 'parentId', 'type', 'createTime','creator','value'],
            colModel: [
                         { msg: 'id', code: 'id', width: 100, sorttype: "int" },
                         { msg: 'msg', code: 'msg', width: 90, sorttype: "date" },
                         { msg: 'appId', code: 'appId', width: 40 },
                         { msg: 'from', code: 'from', width: 40, align: "right", sorttype: "float" },
                         { msg: 'parentId', code: 'parentId', width: 100, align: "right", sorttype: "float" },
                         { msg: 'type', code: 'type', width: 40, align: "right", sorttype: "float" },
                         { msg: 'createTime', code: 'createTime', width: 150, sortable: false },
                         { msg: 'creator', code: 'creator', width: 150, sortable: false },
                         { msg: 'value', code: 'value', width: 80, sortable: false },
            ],
            multiselect: true,
            caption: "session icon data"
        });
    var mydata = iconsList;
    for (var i = 0; i <= mydata.length; i++) {
        jQuery("#list4").jqGrid('addRowData', i + 1, mydata[i]);
    }
}
</script>
</html>

